package uk.co.revisual.creation
{
	import flexunit.framework.Assert;
	
	import uk.co.revisual.domino.proxies.FSMClassFactoryProxy;
	import uk.co.revisual.domino.proxies.FSMModelProxyTest;
	
	public class ClassFactoryTest
	{	
		[Test]		
		/**
		 * Tests adding classes via the constructor arguments
		 * Also tests hasClass and create
		 */
		public function testConstructor():void
		{
			var classes:Array = [ ClassFactoryTest, FSMModelProxyTest, FSMClassFactoryProxy ];
			var testSubject:DynamicClassFactory = new ClassFactory( classes );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.creation.ClassFactoryTest") );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.domino.proxies.FSMModelProxyTest") );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.domino.proxies.FSMClassFactoryProxy") );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.creation.ClassFactoryTest" ), ClassFactoryTest );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.domino.proxies.FSMModelProxyTest" ), FSMModelProxyTest );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.domino.proxies.FSMClassFactoryProxy" ), FSMClassFactoryProxy );
			
		}
		
		/**
		 * Tests adding classes via the addClass method
		 * Also tests hasClass and create
		 */
		[Test]
		public function testAddClass():void
		{
			var testSubject:DynamicClassFactory = new ClassFactory(  );
			testSubject.addClass( ClassFactoryTest );
			testSubject.addClass( [ FSMModelProxyTest, FSMClassFactoryProxy ] );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.creation.ClassFactoryTest") );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.domino.proxies.FSMModelProxyTest") );
			Assert.assertTrue( testSubject.hasClass("uk.co.revisual.domino.proxies.FSMClassFactoryProxy") );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.creation.ClassFactoryTest" ), ClassFactoryTest );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.domino.proxies.FSMModelProxyTest" ), FSMModelProxyTest );
			Assert.assertEquals( testSubject.create( "uk.co.revisual.domino.proxies.FSMClassFactoryProxy" ), FSMClassFactoryProxy );
			
		}
	}
}